{% extends "common/panel.html" %}
{% block title %}{{title}}{% endblock %}

{% block panel %}

<script type="text/javascript" charset="utf-8">
    madrona.onShow(function(){
        madrona.setupForm($('#featureform'));
    });
</script>

{% if form.media %} {{ form.media }} {% endif %}
<h1>{{title}}</h1>

{% if is_spatial %}    
<div class="tabs">
    <ul>
        <li>
            <a href="#PanelGeometry">
                <span>Geometry</span>
            </a>
        </li>
    <li>
        <a href="#PanelAttributes">
            <span>Attributes</span>
        </a>
    </li>
    </ul>
        <div id="PanelGeometry"></div>
        <div id="PanelAttributes">

{% endif %}

            {% if form.is_multipart %}
            <form id="featureform" enctype="multipart/form-data" action="{{action}}" method="post">
                <input type='hidden' name='MAX_FILE_SIZE' value="10485760" /> <!-- 10 MB upload limit -->
            {% else %}
            <form id="featureform" action="{{action}}" method="post"> 
            {% endif %}
            {% if json %}
                <div style="display:none;" class="json">{{json}}</div>
            {% endif %}
            {% for field in form.visible_fields %}
                <div class="field{% if field.field.required %} required{% endif %}">
                {# Include the hidden fields in the form #}
                {% if forloop.first %}
                {% for hidden in form.hidden_fields %}
                <div style="display:none;">
                    {{ hidden.errors }}
                    {{ hidden }}
                </div>
                {% endfor %}
                {% endif %}

                {{ field.label_tag }}
                {{ field.errors }}
                {% if field.help_text %}
                <p class="help_text">
                    {{ field.help_text|safe }}            
                </p>            
                {% endif %}
                {{ field }}            
            </div>
            {% endfor %}
            <p><input type="submit" value="submit"></p>
            </form>
            {% if is_collection %}
              <div class="draghint">
                <h5>Hint</h5>
                <img src="{{MEDIA_URL}}common/images/dragdrophint.png" />
                To add features to this collection, simply drag and drop features in and out of it from the sidebar after saving.
                <br style="clear:both;" />
              </div>
            {% endif %}
{% if is_spatial %}
    
        </div>
{% endif %}

        <br class="clear" />
        <div class="form_controls">
            <a href="#" class="submit_button button" onclick="this.blur(); return false;"><span>Submit</span></a>
            <a href="#" class="cancel_button button red" onclick="this.blur(); return false;"><span>Cancel</span></a>
            <br class="clear" />
        </div>

{% if is_spatial %}
    </div>    
{% endif %}

{% endblock %}
